﻿using MetroDataApi.Models;
using Newtonsoft.Json;
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Net.Http;
using System.Text.RegularExpressions;
using System.Web.Http;


namespace MetroDataApi.Controllers.Management
{
    public class MonitorPointsDictionary2Controller : ApiController
    {


        // GET api/monitorpointsdictionary2/5
        public string Get(int prjId)
        {
            using (var db = new MetroDataDataContext())
            {
                var list = db.MonitorPointsDictionary.Where(p => p.PrjId == prjId).Select(p =>
                    new DictionaryPoint()
                    {
                        Location = p.Location,
                        Milage = p.Mileage,
                        MonitorType = p.MonitorType,
                        Name = p.Name,
                        RingNumber = p.RingNumber
                    });
                var str = JsonConvert.SerializeObject(list);
                return str;
            }
        }

        public class DictionaryPoint
        {
            public string Name { get; set; }
            public string MonitorType { get; set; }
            public string Location { get; set; }
            public string RingNumber { get; set; }
            public string Milage { get; set; }
        }

    }
}
